<?php
//默认列出收到的任务
if ($act == 'list') {
	//获取页码
	if (isset($_GET['page']) && !empty($_GET['page']) && is_numeric($_GET['page'])) {
		$page = abs(intval($_GET['page']));
	} else {
		$page = 0;
	}
	//获取页数
	if (isset($_GET['pagenum']) && !empty($_GET['pagenum']) && is_numeric($_GET['pagenum'])) {
		$pagenum = abs(intval($_GET['pagenum']));
	} else {
		$sql = "SELECT count(*) FROM `".$_C['DB']['PREFIX']."tracks` WHERE `uid` = '1'";
		$result = $conn->query($sql);
		$row = $result->fetch_row();
		$pagenum = ceil($row[0]/$_C['COMMON']['pagesize']);
	}

	$offset = $page*$CONFIG['pagesize'];
	$sql = "SELECT * FROM `".$_C['DB']['PREFIX']."tracks` WHERE `uid` = '1' ORDER BY tid DESC LIMIT ".$offset.", ".$_C['COMMON']['pagesize'];
	$result = $conn->query($sql);
	while($row = $result->fetch_array(MYSQLI_ASSOC)) {
		$rs[] = $row;
	}
	require_once './template/home.temp.php';
}

//发送任务给某人
if ($act == 'post') {
	$sql = "INSERT INTO `".$_C['DB']['PREFIX']."tracks` (`uid`, `fromid`, `fromname`, `message`, `cateid`, `pubtime`) VALUES ('".$_POST['uid']."', '".$_POST['fromid']."', '".$_POST['fromname']."', '".$_POST['message']."', 1, '".time()."')";
	if ($conn->query($sql)) {
		echo 1;
	} else {
		echo 0;
	}
}